/*******************************************************************************
 * Copyright 2011 Towee.net
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package net.towee.client.managers;

import net.towee.client.event.core.DiscussionMessageReceivedEvent;
import net.towee.model.discussion.Discussion;
import net.towee.model.discussion.DiscussionSubject;
import net.towee.model.discussion.Message;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * This manager can get, remove and save comments
 * 
 * <ul>The implementation MUST handler this PUSH events:
 * <li>New or updated message - {@link DiscussionMessageReceivedEvent}</li>
 * </ul>
 * 
 * @author viiv.c58@gmail.com (Artem Artem'ev)
 */
public interface DiscussionManager {
	/**
	 * Get discussion with 30 limit of messages by given id.
	 * @param id
	 * @param subject TODO
	 * @param handler
	 */
	public void getDiscussion(String id, DiscussionSubject subject, AsyncCallback<Discussion> handler);
	
	/**
	 * Get discussion with given id
	 * 
	 * @param id
	 *            of comment
	 * @param subject TODO
	 * @param offset
	 * @param limit
	 * @param handler
	 */
	public void getDiscussion(String id, DiscussionSubject subject, int offset, int limit, AsyncCallback<Discussion> handler);

	/**
	 * Add message to discussion. On success it fire an
	 * {@link DiscussionMessageReceivedEvent} event
	 * @param disc TODO
	 * @param id TODO
	 * @param subject TODO
	 * @param handler
	 * @param comment
	 */
	public void addMessage(Discussion disc, String id, DiscussionSubject subject, Message mess, AsyncCallback<Message> handler);

	/**
	 * Change message text. Given message MUST have valid id and discussion id.
	 * On success it fire an {@link DiscussionMessageReceivedEvent} event
	 * @param disc TODO
	 * @param id TODO
	 * @param subject TODO
	 * @param mess
	 */
	public void changeMessage(Discussion disc, String id, DiscussionSubject subject, Message mess, AsyncCallback<Boolean> handler);

	/**
	 * Remove discussion message
	 * @param discussion
	 * @param id
	 * @param subject
	 * @param message
	 * @param asyncCallback
	 */
	public void removeMessage(Discussion discussion, String id, DiscussionSubject subject,
			Message message, AsyncCallback<Boolean> asyncCallback);
}
